package GameEngine.Gui;

import processing.core.PGraphics;
import processing.core.PImage;
import GameEngine.Gui.Event.IMultiTouchEventListener;
import GameEngine.Gui.Event.TouchEvent;
import GameEngine.helper.Log;
import GameEngine.helper.PAppletBridge;

public class GraphicsButton extends Button implements IMultiTouchEventListener {
	private PImage Background;

	public GraphicsButton(PImage img, int x, int y, int w, int h) {
		super(x, y, w, h);
		Background = img;
	}

	@Override
	public void draw() {
		PAppletBridge.pushMatrix();
		PAppletBridge.imageMode(PAppletBridge.CORNERS);
		PAppletBridge.translate(PosX, PosY);
		PAppletBridge.image(Background, 0, 0);
		updateScreenXY(0,0);
		PAppletBridge.popMatrix();
	}

	public void draw(PGraphics pg) {
		pg.pushMatrix();
		pg.imageMode(PAppletBridge.CORNERS);
		pg.translate(PosX, PosY);
		pg.image(Background, 0, 0);
		pg.popMatrix();
	}

	// Implementierung IMultiTouchEventListener

	@Override
	public void onDrag(TouchEvent e) {
		// TODO Auto-generated method stub
	}

	@Override
	public void onTap(TouchEvent e) {
		// TODO Auto-generated method stub
		Log.warn("Tap");
	}

	@Override
	public void onTouch(TouchEvent e) {
		// TODO Auto-generated method stub
		if (inArea(e)) {
			Log.warn("Touch: " + this);
		}
	}

}
